cmake_minimum_required(VERSION 3.20)

set(CMAKE_CXX_STANDARD 14)
project (PublicElement LANGUAGES CXX)


# source
file(GLOB SOURCES 
    ${CMAKE_CURRENT_SOURCE_DIR}/Common/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/Membrane/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/Plate/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/ShellElement/*.cpp
    )
add_library(${PROJECT_NAME} SHARED ${SOURCES})

# header files directories
target_include_directories(${PROJECT_NAME}
    PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../
    PRIVATE ${CMAKE_INSTALL_PREFIX}/include/)

# link dll
target_link_directories(${PROJECT_NAME} PRIVATE ${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE ElementCalculator Framework ShellSecCalculator Integration DBManager DataStructure Algebra Configuration Logging)

# add_macro: windows class Export
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPORTING_PublicElement)

# Header files install Solver/Element/
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Common/                       DESTINATION include/SGFem/PublicElement/Common FILES_MATCHING PATTERN "*.h" PATTERN "UnitTest" EXCLUDE)

# install(DIRECTORY ${PROJECT_SOURCE_DIR}/Interface/       DESTINATION include/Solver/PublicElement/Interface)
# install(DIRECTORY ${PROJECT_SOURCE_DIR}/Factory/include/ DESTINATION include/Solver/PublicElement/Factory/include)

install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin)

# Test subproject
if (SG_BUILD_UNIT_TEST)
    add_subdirectory(test)
endif()
